﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;


namespace Tunynet.MobileSMS
{
    /// <summary>
    /// 手机验证
    /// </summary>
   public static  class GeneralRegex
    {
       /// <summary>
       /// 验证是否是手机号
       /// </summary>
       /// <param name="source"></param>
       /// <returns></returns>
       public static bool IsMobile(string source)
       {
           return Regex.IsMatch(source, "^(?:(?:(?:(?:133)|(?:153)|(?:180)|(?:181)|(?:189)|(?:130)|(?:131)|(?:132)|(?:145)|(?:155)|(?:156)|(?:185)|(?:186)|(?:135)|(?:136)|(?:137)|(?:138)|(?:139)|(?:147)|(?:150)|(?:151)|(?:152)|(?:157)|(?:158)|(?:159)|(?:182)|(?:183)|(?:184)|(?:187)|(?:188))\\d{8})|(?:(?:(?:1340)|(?:1341)|(?:1342)|(?:1343)|(?:1344)|(?:1345)|(?:1346)|(?:1347)|(?:1348)|(?:1349))\\d{7}))$");
       }

       /// <summary>
       /// 验证是否是邮箱号
       /// </summary>
       /// <param name="source"></param>
       /// <returns></returns>
       public static bool IsEmail(string source)
       {
           return Regex.IsMatch(source, "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", RegexOptions.IgnoreCase);
       }
    }
}
